package googleearthdownloader;

import java.util.Vector;

public class FilesToDownloadList {
	
	Vector<DownloadableImage> imagesToDownload;
	int numberOfDownloadedFiles, totalNumberOfFiles;
	
	public FilesToDownloadList(){
		numberOfDownloadedFiles = 0;
		totalNumberOfFiles = 0;
		imagesToDownload = new Vector<DownloadableImage>();
	}
	
	public synchronized DownloadableImage checkOut(int i){
		
		if(imagesToDownload.size()>0){
			return imagesToDownload.remove(i);
		}
		else{
			return null;
		}
		
	}
	
	public synchronized boolean add(DownloadableImage image){
		totalNumberOfFiles++;
		return imagesToDownload.add(image);
	}
	
	public synchronized void downloaded(){
		numberOfDownloadedFiles++;
	}
	
	public synchronized void fileNotFound(DownloadableImage image){
		totalNumberOfFiles--;
	}
	
	public synchronized int getNumberOfDownloadedFiles(){
		return numberOfDownloadedFiles;
	}
	
	public synchronized int getTotalNumberOfFiles(){
		return totalNumberOfFiles;
	}
	
	public synchronized int getNumberOfFilesToDownload(){
		return getTotalNumberOfFiles()-getNumberOfDownloadedFiles();
	}
	
}
